/*

Author   : chaos

FileName : use_this.cpp

Date     : 12/08/17 16:12:51

*/
#include <iostream>
using namespace std;

class this_ptr
{
    private:
        long index;
    public:
        void show_index()
        {cout << "index : " << index << endl;}

        this_ptr * setindex(long i_index);
};

this_ptr * this_ptr::setindex(long i_index)
{
    index = i_index;
    return this;
}

int main(int argc ,char *argv[])
{
    this_ptr object, * object_ptr;

    object_ptr = object.setindex(1);

    cout << "object address : "  << &object << endl;

    cout << "pointer : " << object_ptr << endl;

    object.setindex(2) ->show_index();

    return 0;
}
